import React from "react";
import "./Card.css";
//商品卡片页面
class Card extends React.Component {
    constructor(props) {
        super(props);
        // console.log(props);
    }

    render() {
        return (
            <div className="card_conte">
                <div className="card_list">商品列表</div>
                <div className="card_goods">
                    {
                        // 循环传递过来的数据，进行展示
                        this.props.list.map((item, index) => {
                            //返回加样式的商品卡片
                            return <div className="card_box" key={index}>
                                <img src={item.mainPic} onClick={() => {
                                    this.props.history.push({
                                        pathname: "/details",
                                        state: {
                                            goods: item
                                        }
                                    })
                                }}></img>
                                <p>{item.title}</p>
                                <p>￥{item.originalPrice}</p>
                            </div>
                        })
                    }
                </div>
            </div>
        )
    }
}

export default Card